Remove gtk_widget_get_preferred_*
authorTimm Bäder <mail@baedert.org>
Tue, 2 May 2017 19:50:50 +0000 (21:50 +0200)
committerTimm Bäder <mail@baedert.org>
Fri, 5 May 2017 09:18:25 +0000 (11:18 +0200)
They are unnecessary now that we have gtk_widget_measure.

docs/reference/gtk/gtk4-sections.txt
gtk/gtksizerequest.c
gtk/gtkwidget.h
testsuite/gtk/scrolledwindow.c

index e74f9c5c263a08a13e6f23b67800403049c7e1ad..a40491c52243d4532f62f2504fa31fa1561ffd8e 100644 (file)
@@ -4661,11 +4661,6 @@ gtk_requisition_free
 <SUBSECTION Width-for-Height>
 GtkSizeRequestMode
 GtkRequestedSize
-gtk_widget_get_preferred_height
-gtk_widget_get_preferred_width
-gtk_widget_get_preferred_height_for_width
-gtk_widget_get_preferred_width_for_height
-gtk_widget_get_preferred_height_and_baseline_for_width
 gtk_widget_get_request_mode
 gtk_widget_get_preferred_size
 gtk_distribute_natural_allocation
index a94dd1d3e4c46a68af8aa5fae8a11153eb95e2b4..0b06b5cec11380863f9e5d74885d0412d0fa82b5 100644 (file)
@@ -445,149 +445,6 @@ gtk_widget_get_request_mode (GtkWidget *widget)
   return cache->request_mode;
 }
 
-/**
- * gtk_widget_get_preferred_width:
- * @widget: a #GtkWidget instance
- * @minimum_width: (out) (allow-none): location to store the minimum width, or %NULL
- * @natural_width: (out) (allow-none): location to store the natural width, or %NULL
- *
- * Retrieves a widget’s initial minimum and natural width.
- *
- * This call is specific to height-for-width requests.
- *
- * The returned request will be modified by the
- * GtkWidgetClass::adjust_size_request virtual method and by any
- * #GtkSizeGroups that have been applied. That is, the returned request
- * is the one that should be used for layout, not necessarily the one
- * returned by the widget itself.
- *
- * Since: 3.0
- */
-void
-gtk_widget_get_preferred_width (GtkWidget *widget,
-                                gint      *minimum_width,
-                                gint      *natural_width)
-{
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-  g_return_if_fail (minimum_width != NULL || natural_width != NULL);
-
-  gtk_widget_measure (widget,
-                      GTK_ORIENTATION_HORIZONTAL,
-                      -1,
-                      minimum_width,
-                      natural_width,
-                      NULL, NULL);
-}
-
-
-/**
- * gtk_widget_get_preferred_height:
- * @widget: a #GtkWidget instance
- * @minimum_height: (out) (allow-none): location to store the minimum height, or %NULL
- * @natural_height: (out) (allow-none): location to store the natural height, or %NULL
- *
- * Retrieves a widget’s initial minimum and natural height.
- *
- * This call is specific to width-for-height requests.
- *
- * The returned request will be modified by the
- * GtkWidgetClass::adjust_size_request virtual method and by any
- * #GtkSizeGroups that have been applied. That is, the returned request
- * is the one that should be used for layout, not necessarily the one
- * returned by the widget itself.
- *
- * Since: 3.0
- */
-void
-gtk_widget_get_preferred_height (GtkWidget *widget,
-                                 gint      *minimum_height,
-                                 gint      *natural_height)
-{
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-  g_return_if_fail (minimum_height != NULL || natural_height != NULL);
-
-  gtk_widget_measure (widget,
-                      GTK_ORIENTATION_VERTICAL,
-                      -1,
-                      minimum_height,
-                      natural_height,
-                      NULL, NULL);
-}
-
-
-
-/**
- * gtk_widget_get_preferred_width_for_height:
- * @widget: a #GtkWidget instance
- * @height: the height which is available for allocation
- * @minimum_width: (out) (allow-none): location for storing the minimum width, or %NULL
- * @natural_width: (out) (allow-none): location for storing the natural width, or %NULL
- *
- * Retrieves a widget’s minimum and natural width if it would be given
- * the specified @height.
- *
- * The returned request will be modified by the
- * GtkWidgetClass::adjust_size_request virtual method and by any
- * #GtkSizeGroups that have been applied. That is, the returned request
- * is the one that should be used for layout, not necessarily the one
- * returned by the widget itself.
- *
- * Since: 3.0
- */
-void
-gtk_widget_get_preferred_width_for_height (GtkWidget *widget,
-                                           gint       height,
-                                           gint      *minimum_width,
-                                           gint      *natural_width)
-{
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-  g_return_if_fail (minimum_width != NULL || natural_width != NULL);
-  g_return_if_fail (height >= 0);
-
-  gtk_widget_measure (widget,
-                      GTK_ORIENTATION_HORIZONTAL,
-                      height,
-                      minimum_width,
-                      natural_width,
-                      NULL, NULL);
-}
-
-/**
- * gtk_widget_get_preferred_height_for_width:
- * @widget: a #GtkWidget instance
- * @width: the width which is available for allocation
- * @minimum_height: (out) (allow-none): location for storing the minimum height, or %NULL
- * @natural_height: (out) (allow-none): location for storing the natural height, or %NULL
- *
- * Retrieves a widget’s minimum and natural height if it would be given
- * the specified @width.
- *
- * The returned request will be modified by the
- * GtkWidgetClass::adjust_size_request virtual method and by any
- * #GtkSizeGroups that have been applied. That is, the returned request
- * is the one that should be used for layout, not necessarily the one
- * returned by the widget itself.
- *
- * Since: 3.0
- */
-void
-gtk_widget_get_preferred_height_for_width (GtkWidget *widget,
-                                           gint       width,
-                                           gint      *minimum_height,
-                                           gint      *natural_height)
-{
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-  g_return_if_fail (minimum_height != NULL || natural_height != NULL);
-  g_return_if_fail (width >= 0);
-
-  gtk_widget_measure (widget,
-                      GTK_ORIENTATION_VERTICAL,
-                      width,
-                      minimum_height,
-                      natural_height,
-                      NULL, NULL);
-}
-
 /*
  * _gtk_widget_get_preferred_size_and_baseline:
  * @widget: a #GtkWidget instance
@@ -622,7 +479,8 @@ _gtk_widget_get_preferred_size_and_baseline (GtkWidget      *widget,
 
   if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
     {
-      gtk_widget_get_preferred_width (widget, &min_width, &nat_width);
+      gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL, -1,
+                          &min_width, &nat_width, NULL, NULL);
 
       if (minimum_size)
        {
@@ -648,15 +506,15 @@ _gtk_widget_get_preferred_size_and_baseline (GtkWidget      *widget,
       if (minimum_size)
        {
          minimum_size->height = min_height;
-         gtk_widget_get_preferred_width_for_height (widget, min_height,
-                                                     &minimum_size->width, NULL);
+          gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL, min_height,
+                              &minimum_size->width, NULL, NULL, NULL);
        }
 
       if (natural_size)
        {
          natural_size->height = nat_height;
-         gtk_widget_get_preferred_width_for_height (widget, nat_height,
-                                                     NULL, &natural_size->width);
+          gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL, nat_height,
+                              NULL, &natural_size->width, NULL, NULL);
        }
     }
 }
index 9c3de471e9d7e2f916c084c7d8a73c0fe98aa0fe..60f5a7fd2a19a69d45718ffc730e6d7f270d0515 100644 (file)
@@ -551,24 +551,6 @@ void          gtk_widget_size_allocate_with_baseline         (GtkWidget           *widget,
 
 GDK_AVAILABLE_IN_ALL
 GtkSizeRequestMode  gtk_widget_get_request_mode               (GtkWidget      *widget);
-GDK_AVAILABLE_IN_ALL
-void                gtk_widget_get_preferred_width            (GtkWidget      *widget,
-                                                               gint           *minimum_width,
-                                                               gint           *natural_width);
-GDK_AVAILABLE_IN_ALL
-void                gtk_widget_get_preferred_height_for_width (GtkWidget      *widget,
-                                                               gint            width,
-                                                               gint           *minimum_height,
-                                                               gint           *natural_height);
-GDK_AVAILABLE_IN_ALL
-void                gtk_widget_get_preferred_height           (GtkWidget      *widget,
-                                                               gint           *minimum_height,
-                                                               gint           *natural_height);
-GDK_AVAILABLE_IN_ALL
-void                gtk_widget_get_preferred_width_for_height (GtkWidget      *widget,
-                                                               gint            height,
-                                                               gint           *minimum_width,
-                                                               gint           *natural_width);
 GDK_AVAILABLE_IN_3_90
 void gtk_widget_measure (GtkWidget      *widget,
                          GtkOrientation  orientation,
index a54e85cb1559cfe2e2740e1ce8cd80a1a235d8d9..c0a4df7e53df735b0e1d1e5731e7703e72b9ce18 100644 (file)
@@ -33,7 +33,8 @@ test_size (GtkOrientation orientation,
         {
           gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW (scrolledwindow), MIN_SIZE);
 
-          gtk_widget_get_preferred_width (scrolledwindow, &size, NULL);
+          gtk_widget_measure (scrolledwindow, GTK_ORIENTATION_HORIZONTAL, -1,
+                              &size, NULL, NULL, NULL);
 
           g_assert_cmpint (size, ==, MIN_SIZE);
         }
@@ -47,8 +48,10 @@ test_size (GtkOrientation orientation,
            * Here, the content is purposely bigger than the scrolled window,
            * so it should grow up to max-content-width.
            */
-          gtk_widget_get_preferred_width (scrolledwindow, NULL, &size);
-          gtk_widget_get_preferred_width (box, &child_size, NULL);
+          gtk_widget_measure (scrolledwindow, GTK_ORIENTATION_HORIZONTAL, -1,
+                              NULL, &size, NULL, NULL);
+          gtk_widget_measure (box, GTK_ORIENTATION_HORIZONTAL, -1,
+                              &child_size, NULL, NULL, NULL);
 
           g_assert_cmpint (child_size, ==, BOX_SIZE);
           g_assert_cmpint (size, ==, MAX_SIZE);
@@ -61,7 +64,8 @@ test_size (GtkOrientation orientation,
         {
           gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (scrolledwindow), MIN_SIZE);
 
-          gtk_widget_get_preferred_height (scrolledwindow, &size, NULL);
+          gtk_widget_measure (scrolledwindow, GTK_ORIENTATION_HORIZONTAL, -1,
+                              &size, NULL, NULL, NULL);
 
           g_assert_cmpint (size, ==, MIN_SIZE);
         }
@@ -75,8 +79,10 @@ test_size (GtkOrientation orientation,
            * Here, the content is purposely bigger than the scrolled window,
            * so it should grow up to max-content-height.
            */
-          gtk_widget_get_preferred_height (scrolledwindow, NULL, &size);
-          gtk_widget_get_preferred_height (box, &child_size, NULL);
+          gtk_widget_measure (scrolledwindow, GTK_ORIENTATION_VERTICAL, -1,
+                              NULL, &size, NULL, NULL);
+          gtk_widget_measure (box, GTK_ORIENTATION_VERTICAL, -1,
+                              &child_size, NULL, NULL, NULL);
 
           g_assert_cmpint (child_size, ==, BOX_SIZE);
           g_assert_cmpint (size, ==, MAX_SIZE);